/**
 * User-Agent 中文名叫用户代理，它是一个特殊的字符串，使得服务器能够识别
 * 客户使用的操作系统及版本、CPU类型、浏览器及版本、浏览器渲染引擎
 * 
 * 
 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36

 Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1


Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Mobile Safari/537.36
 * 
 */

let http = require('http')
let parse = require("user-agent-parser")
let server = http.createServer(function(req,res){
    let UserAgent = req.headers['user-agent']
    console.log(UserAgent)
    let userAgentObj = parse(UserAgent)
    res.end(JSON.stringify(userAgentObj))
})
server.listen(8080)